import 'package:cher_flare/common/widgets/ly_common_app_bar.dart';
import 'package:cher_flare/routes/app_pages.dart';
import 'package:cher_flare/utils/app_color.dart';
import 'package:cher_flare/utils/size_fit.dart';
import 'package:cher_flare/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';

import '../../http/http_config.dart';

class LYAboutAppPage extends StatefulWidget {
  const LYAboutAppPage({super.key});

  @override
  State<LYAboutAppPage> createState() => _LYAboutAppPageState();
}

class _LYAboutAppPageState extends State<LYAboutAppPage> {
  String? version;
  @override
  void initState() {
    super.initState();
    _loadAppInfo();
  }

  void _loadAppInfo() async {
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    version = packageInfo.version;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Utils.commonAppBar(title: 'About'),
      backgroundColor: AppColors.whiteColor,
      body: Container(
        alignment: Alignment.center,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const SizedBox(
              height: 40,
            ),
            Image.asset(
              'assets/images/logo.png',
              width: 88,
              height: 88,
            ),
            const Padding(
              padding: EdgeInsets.symmetric(vertical: 14),
              child: Text(
                'CherFlare',
                style: TextStyle(fontSize: 16, color: AppColors.color404040),
              ),
            ),
            Text(
              'Version  $version',
              style:
                  const TextStyle(fontSize: 12, color: AppColors.color17BC14),
            ),
            const SizedBox(
              height: 67,
            ),
            InkWell(
              onTap: () {
                Get.toNamed(AppPages.webView, arguments: {
                  'urlString': HttpConfig.termConditions,
                  'title': 'Term of Use',
                  'type': 1
                });
              },
              child: Container(
                height: 48.px,
                alignment: Alignment.centerLeft,
                padding: const EdgeInsets.only(left: 15),
                margin: const EdgeInsets.only(left: 16, right: 16),
                decoration: BoxDecoration(
                  color: AppColors.colorF6F8FA,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: const Text(
                  'Terms and Conditons',
                  style: TextStyle(fontSize: 16, color: AppColors.color404040),
                ),
              ),
            ),
            const SizedBox(
              height: 16,
            ),
            InkWell(
              onTap: () {
                Get.toNamed(AppPages.webView, arguments: {
                  'urlString': HttpConfig.privacyPolicy,
                  'title': 'Privacy Policy',
                  'type': 0
                });
              },
              child: Container(
                height: 48.px,
                alignment: Alignment.centerLeft,
                padding: const EdgeInsets.only(left: 15),
                margin: const EdgeInsets.only(left: 16, right: 16),
                decoration: BoxDecoration(
                  color: AppColors.colorF6F8FA,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: const Text(
                  'Privacy Policy',
                  style: TextStyle(fontSize: 16, color: AppColors.color404040),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
